package net.javamine.util;

import org.apache.log4j.Logger;

/**
 * 异常工具类
 * 
 * @author <a href="mailto: java_lht@163.com">Lht</a>
 * @since 2012-5-24 1.create
 */
public class ExceptionUtils {
	
	public static void getExceptionMessage(Logger log, Exception e) {
		if (log!=null && e!=null) {
			if (e.toString().indexOf("ConstraintViolationException") != -1) {
				log.error("Exception: " + e.getClass().getName() + " Message: "
						+ e.getMessage());
			}
			if (log.isInfoEnabled()) {
				log.error("Exception: " + e.getClass().getName() + " Message: "
						+ e.getMessage());
			}
			if (log.isDebugEnabled()) {
				e.printStackTrace();
			}
		} else {
			log.error("Logger or Exception is null.");
		}
	}

}
